Skip to content

test(cli): stop the chDB streak test leaking exit code 78 - #3271

Merged
Makisuo merged 1 commit into
mainfrom
fix/cli-test-exit-code-leak
Dec 4, 2026
Merged

Makisuo merged 1 commit into
mainfrom
fix/cli-test-exit-code-leak

Conversation

@Makisuo

@Makisuo Makisuo commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

The apps/cli test job sometimes fails with every test passing and script "test" exited with code 78 (seen on #3268 and #3270).

Cause: test/in-memory-store.test.ts ("keeps the failure streak across runs") saves process.exitCode, runs a chDB refusal that sets 78, then writes the saved value back. When the saved value was undefined, that write is a no-op in Bun, so the 78 stays. Whether the saved value is undefined depends on whether an earlier file in the run set the exit code, so the failure is flaky. expected-outcomes.test.ts already guards against the same trap with ?? 0. This applies the same fix.

Evidence:

  • bun test test/in-memory-store.test.ts alone: before, 13 pass, 0 fail, exit code 78. After, exit code 0.
  • Whole CLI suite locally: the only failures need the effect-sdk build or libchdb, which this worktree doesn't have and CI builds.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Tests
    • Improved CLI test cleanup so test runs handle unset exit statuses consistently across runtimes, reducing the chance that one test affects the results of another.
  • User impact
    • No user-visible behavior changes.

…streak test

Assigning undefined back to process.exitCode is a no-op in Bun, so the 78
a chDB refusal sets leaked out whenever this file ran before any other set
the exit code: the CLI suite failed with every test passing.
@maple-review-bot

maple-review-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. One-line test fix that matches the existing ?? 0 pattern in expected-outcomes.test.ts:38; nothing in production code changes.
no findings · tests not needed · risk low

The streak test now restores process.exitCode to 0 instead of assigning undefined, so the 78 a chDB refusal sets can no longer leak into the CLI test job. Correct and safe to merge.

08f1732 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The inMemoryStartFailuresKey test now restores process.exitCode to its saved value, or to 0 when that value is undefined. A comment documents the Bun behavior behind the fallback.

Changes: Test Exit-Code Restoration

Layer / File(s) Summary
Restore the test exit code
apps/cli/test/in-memory-store.test.ts
The test defaults an undefined saved process.exitCode to 0. A comment explains the Bun behavior.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Possibly related PRs

Suggested reviewers: jeremyfunk

Merge Risk: Minimal · up to 08f17

This is a test-only change that keeps a leaked exit code 78 from failing the CLI test job. It does not change production behavior, and the merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: a test fix that stops the chDB streak test from leaking exit code 78. The raw summary confirms the change restores process.exitCode with a ?? 0 fallback in apps/cli/test/…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: a test fix that stops the chDB streak test from leaking exit code 78. The raw summary confirms the change restores process.exitCode with a ?? 0 fallback in apps/cli/test/in-memory-store.test.ts, and the objectives describe the same leak. The title is specific and matches the main change. It uses the conventional test(cli): prefix and stays under one line.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8491e36-e7a7-4c62-8894-08cb08b0a33d
Commits

Reviewing files that changed from the base of the PR and between 01fb8ce and 08f1732.

Files selected for processing: 1

  • apps/cli/test/in-memory-store.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@Makisuo
Makisuo merged commit 21cd826 into main Dec 4, 2026
29 checks passed
@Makisuo
Makisuo deleted the fix/cli-test-exit-code-leak branch December 4, 2026 16:18
Makisuo added a commit that referenced this pull request Dec 4, 2026
…streak test (#3271)

Assigning undefined back to process.exitCode is a no-op in Bun, so the 78
a chDB refusal sets leaked out whenever this file ran before any other set
the exit code: the CLI suite failed with every test passing.
Makisuo added a commit that referenced this pull request Dec 4, 2026
… series (#3274)

* feat(infra): show used / total figures beside the CPU, memory and disk percents

Infra pages showed CPU / memory / disk as bare percents. "Memory 62%" says nothing about whether that is
1 GB or 100 GB, and a pod at 98% of its limit reads the same whether the limit is 64 MB or 4 GB. This puts
the absolute figure beside each percent (tables, stat cards, chart legends and tooltips), from metrics the
collectors already send. A figure is shown only where the data gives one; otherwise the percent stands alone.

Hosts (`listHostsQuery`, `hostDetailSummaryQuery`)
- CPU: busy cores = busy share × `system.cpu.logical.count` ("7.52 / 8 cores").
- Memory: `system.memory.usage{state=used}`; the hostmetrics receiver sends no total and its states do
  not sum to one (`cached` includes `slab_reclaimable`), so total = used bytes ÷ the used share within each
  scrape, averaged over scrapes that carried both ("9.9 GB / 16.0 GB"). Checked against `/proc/meminfo`
  MemTotal byte for byte. All three metrics are read from `metrics_sum` and `metrics_gauge` (the exporter
  routes by data-point type; senders differ), grouped per host and scrape across both.
- Disk: the fullest mount's used and used + free bytes from `system.filesystem.usage`, from the very reading
  its percent comes from (`argMaxIf` on the same mount and freshness rule `diskPct` uses), so used / total
  == diskPct ("41.0 GB / 100 GB"); on a timestamp tie the reading with bytes gives the percent. A used/free
  pair from two scrapes, one state alone, or a newer utilization-only reading gives the percent alone. A
  usage scrape with one state is no fraction at all (it would read 100%), so the mount list and chart skip
  it too. Host detail reads the figures for its one host, not the org.
- Detail charts: CPU states read as cores of the host, memory states as bytes of its total, and each mount
  as bytes of its size (`hostFilesystemTotalsQuery`: used + free per mount, only while it held still) —
  "45% · 7.2 GB" in the legend and tooltip. The totals definition has its own cache revision, since it
  shares the series' id and payload.

Pods (`listPodsQuery`, `podDetailSummaryQuery`): the kubelet sends limit and request shares, not limits, so
each limit or request is usage ÷ share within one sample (one pod by UID, one scrape), and is given only
when every sample agrees and no sample has usage without its share. Then usage over it is exactly the
share beside it, peak or average; a limit resized within the window, samples that disagree, or a pod
without the share show usage alone. The list meters read "0.022 / 2.1 cores",
"1.8 GB / 2.1 GB"; the detail page's four share cards carry the same figures, and its limit and request
charts read as cores or bytes. The summary band reads the same metric set as the list.

Workloads (`listWorkloadsQuery`, `workloadDetailSummaryQuery`): the same per-sample divisor, given only when
every pod of the workload ran under one limit. The list's peak meters and the detail cards and charts then
carry cores and bytes; workloads whose pods run under different limits keep the percent alone.

Nodes: the utilization charts read as cores and bytes of allocatable (the cards already carried them).

Containers (`listContainersQuery`, `containerCountersSummaryQuery`): memory reads usage of the limit from
the docker_stats `container.memory.usage.total` / `.limit` sums, filtered by the list's own filters (an
image filter keeps a reused name's old image out) and left-joined per (name, host); their ratio equals
`container.memory.percent`. A limit that changed within the window gives no figure. Docker's CPU percent is
not a share of a core count, so CPU has no figure.

Supabase: the memory and disk cells, the degraded reason and the overview finding carry bytes of the
project's memory and disk size.

Figures beside a share of a limit or request are share × divisor (`formatShareOfLimit`), so they always read
as the percent beside them; usage stands alone only where there is no limit. A pod name reused across two
clusters folds both into one row, and a usage peak from one beside a share from the other no longer disagrees.

Charts: `InfraMetric` specs take an optional `absolute` (`{ unit, totals }` by series, `*` for all), and
`formatSeriesValue` adds the figure in legends and tooltips; the axis stays in percent.

Compatibility: every new response field is a `Schema.optionalKey` (0 or absent = not sent), so a web build
with them still decodes an older API's response and shows percents only. A missing metric never renders an
invented "0 cores" / "0 B".

Layout (Effect UI pages): `MeterRows` takes an optional `detail` per row in a fixed 112 px lane;
`figureLane: true` keeps the lane for a row with no figure, so a table draws every bar at one length and every
percent in one column. The host, pod and container tables key their lanes on the page column
(`@container/page`) instead of the viewport, since the sidebar narrows it; the lanes live in one place
(`FLEET_LANES`, `InfraCells.ts`). Below 800 px of page the meters read under the name. Narrow single-meter
cells (nodes, workload peaks) put the figure under the meter instead (`CaptionedMeter`), so no column widens.

Tests: query-engine infra/containers suites (per-sample divisors, same-reading disk bytes, container byte
filters, filesystem totals), `formatSeriesValue`, the figure formatters and `podAbsolute`, the Supabase degraded
reasons, the host findings, the regenerated SQL baseline, and the infra pages' parity baselines (regenerated:
every change adds the figure lane and its text; the cost page's parity failures are upstream's own).
Live-checked on a 78-pod / 20-host / 18-container fleet: every figure ÷ its divisor equals the percent beside
it.

* perf(infra): derive host totals and pod limits with one row per host or pod

The memory total and the pod limits were paired per scrape, so the group
grew with hosts or pods times scrapes in the window. They are now plain
per-key aggregates: total = avg used bytes / avg used share, and a limit is
usage / share at the highest sample, the lowest and the total, given only
when the three agree and every usage sample has its share. Same figures on
real data. The filesystem totals query gets its own cache id.

* feat(warehouse): infra_metrics_hourly, hourly host, k8s and container series

One row per infra series, hour and retention period from metrics_sum and
metrics_gauge, with the resource and point attributes cut to the keys the
infra pages read. The per-core cpu attribute is dropped, so a host's CPU
states fold into one row. Rows carry sum, count, max, min, positive-only
stats, first and last seen, and earliest, latest and peak-time states,
enough for every aggregate the infra list and detail queries take.

RetentionDays is copied from the raw points and partitions the table like
the raw tables do, so an hour of a short-period source expires with its
points. Migration 0078 backfills 90 days before the views exist; Tinybird
replays history on the first deploy (not in SKIP_BACKFILL). Local schema
v70.

* chore(views): regenerate the kit index for MeterRows figures and CaptionedMeter

* fix(warehouse): keep container.pids.count in infra_metrics_hourly

The container summary reads it beside the memory and restart counters the
rollup already keeps.

* test(cli): restore the exit code to 0, not undefined, after the chDB streak test (#3271)

Assigning undefined back to process.exitCode is a no-op in Bun, so the 78
a chDB refusal sets leaked out whenever this file ran before any other set
the exit code: the CLI suite failed with every test passing.

---------

Co-authored-by: Raisal P Wardana <IEatCodeDaily@users.noreply.github.com>
Makisuo added a commit that referenced this pull request Dec 4, 2026
…#3275)

* feat(infra): show used / total figures beside the CPU, memory and disk percents

Infra pages showed CPU / memory / disk as bare percents. "Memory 62%" says nothing about whether that is
1 GB or 100 GB, and a pod at 98% of its limit reads the same whether the limit is 64 MB or 4 GB. This puts
the absolute figure beside each percent (tables, stat cards, chart legends and tooltips), from metrics the
collectors already send. A figure is shown only where the data gives one; otherwise the percent stands alone.

Hosts (`listHostsQuery`, `hostDetailSummaryQuery`)
- CPU: busy cores = busy share × `system.cpu.logical.count` ("7.52 / 8 cores").
- Memory: `system.memory.usage{state=used}`; the hostmetrics receiver sends no total and its states do
  not sum to one (`cached` includes `slab_reclaimable`), so total = used bytes ÷ the used share within each
  scrape, averaged over scrapes that carried both ("9.9 GB / 16.0 GB"). Checked against `/proc/meminfo`
  MemTotal byte for byte. All three metrics are read from `metrics_sum` and `metrics_gauge` (the exporter
  routes by data-point type; senders differ), grouped per host and scrape across both.
- Disk: the fullest mount's used and used + free bytes from `system.filesystem.usage`, from the very reading
  its percent comes from (`argMaxIf` on the same mount and freshness rule `diskPct` uses), so used / total
  == diskPct ("41.0 GB / 100 GB"); on a timestamp tie the reading with bytes gives the percent. A used/free
  pair from two scrapes, one state alone, or a newer utilization-only reading gives the percent alone. A
  usage scrape with one state is no fraction at all (it would read 100%), so the mount list and chart skip
  it too. Host detail reads the figures for its one host, not the org.
- Detail charts: CPU states read as cores of the host, memory states as bytes of its total, and each mount
  as bytes of its size (`hostFilesystemTotalsQuery`: used + free per mount, only while it held still) —
  "45% · 7.2 GB" in the legend and tooltip. The totals definition has its own cache revision, since it
  shares the series' id and payload.

Pods (`listPodsQuery`, `podDetailSummaryQuery`): the kubelet sends limit and request shares, not limits, so
each limit or request is usage ÷ share within one sample (one pod by UID, one scrape), and is given only
when every sample agrees and no sample has usage without its share. Then usage over it is exactly the
share beside it, peak or average; a limit resized within the window, samples that disagree, or a pod
without the share show usage alone. The list meters read "0.022 / 2.1 cores",
"1.8 GB / 2.1 GB"; the detail page's four share cards carry the same figures, and its limit and request
charts read as cores or bytes. The summary band reads the same metric set as the list.

Workloads (`listWorkloadsQuery`, `workloadDetailSummaryQuery`): the same per-sample divisor, given only when
every pod of the workload ran under one limit. The list's peak meters and the detail cards and charts then
carry cores and bytes; workloads whose pods run under different limits keep the percent alone.

Nodes: the utilization charts read as cores and bytes of allocatable (the cards already carried them).

Containers (`listContainersQuery`, `containerCountersSummaryQuery`): memory reads usage of the limit from
the docker_stats `container.memory.usage.total` / `.limit` sums, filtered by the list's own filters (an
image filter keeps a reused name's old image out) and left-joined per (name, host); their ratio equals
`container.memory.percent`. A limit that changed within the window gives no figure. Docker's CPU percent is
not a share of a core count, so CPU has no figure.

Supabase: the memory and disk cells, the degraded reason and the overview finding carry bytes of the
project's memory and disk size.

Figures beside a share of a limit or request are share × divisor (`formatShareOfLimit`), so they always read
as the percent beside them; usage stands alone only where there is no limit. A pod name reused across two
clusters folds both into one row, and a usage peak from one beside a share from the other no longer disagrees.

Charts: `InfraMetric` specs take an optional `absolute` (`{ unit, totals }` by series, `*` for all), and
`formatSeriesValue` adds the figure in legends and tooltips; the axis stays in percent.

Compatibility: every new response field is a `Schema.optionalKey` (0 or absent = not sent), so a web build
with them still decodes an older API's response and shows percents only. A missing metric never renders an
invented "0 cores" / "0 B".

Layout (Effect UI pages): `MeterRows` takes an optional `detail` per row in a fixed 112 px lane;
`figureLane: true` keeps the lane for a row with no figure, so a table draws every bar at one length and every
percent in one column. The host, pod and container tables key their lanes on the page column
(`@container/page`) instead of the viewport, since the sidebar narrows it; the lanes live in one place
(`FLEET_LANES`, `InfraCells.ts`). Below 800 px of page the meters read under the name. Narrow single-meter
cells (nodes, workload peaks) put the figure under the meter instead (`CaptionedMeter`), so no column widens.

Tests: query-engine infra/containers suites (per-sample divisors, same-reading disk bytes, container byte
filters, filesystem totals), `formatSeriesValue`, the figure formatters and `podAbsolute`, the Supabase degraded
reasons, the host findings, the regenerated SQL baseline, and the infra pages' parity baselines (regenerated:
every change adds the figure lane and its text; the cost page's parity failures are upstream's own).
Live-checked on a 78-pod / 20-host / 18-container fleet: every figure ÷ its divisor equals the percent beside
it.

* perf(infra): derive host totals and pod limits with one row per host or pod

The memory total and the pod limits were paired per scrape, so the group
grew with hosts or pods times scrapes in the window. They are now plain
per-key aggregates: total = avg used bytes / avg used share, and a limit is
usage / share at the highest sample, the lowest and the total, given only
when the three agree and every usage sample has its share. Same figures on
real data. The filesystem totals query gets its own cache id.

* feat(warehouse): infra_metrics_hourly, hourly host, k8s and container series

One row per infra series, hour and retention period from metrics_sum and
metrics_gauge, with the resource and point attributes cut to the keys the
infra pages read. The per-core cpu attribute is dropped, so a host's CPU
states fold into one row. Rows carry sum, count, max, min, positive-only
stats, first and last seen, and earliest, latest and peak-time states,
enough for every aggregate the infra list and detail queries take.

RetentionDays is copied from the raw points and partitions the table like
the raw tables do, so an hour of a short-period source expires with its
points. Migration 0078 backfills 90 days before the views exist; Tinybird
replays history on the first deploy (not in SKIP_BACKFILL). Local schema
v70.

* perf(infra): read hosts, pods and workloads from infra_metrics_hourly

The infra list and detail queries aggregate per-series partials: whole
hours from infra_metrics_hourly, the partial hours at the ends from raw
points, so a 7-day window no longer scans every raw point. Each query
names the attribute keys it reads, and reading any other key is a type
error. Pod and workload limits come from the same pass as their row, so
the second scan and its join are gone.

A window of six hours or more takes its start on the hour: raw points
sort by series then time, so a raw edge costs its whole day partition.
A cluster without migration 0078 falls back to raw points (the API,
the MCP tools), and the chDB suite holds every routed read equal to its
raw twin.

* chore(views): regenerate the kit index for MeterRows figures and CaptionedMeter

* fix(warehouse): keep container.pids.count in infra_metrics_hourly

The container summary reads it beside the memory and restart counters the
rollup already keeps.

* test(infra): parity over a snapped long window; log the MCP raw fallback

A window of six hours or more reaches the engine with its start on the
hour, so the rollup reads the first hour whole: the chDB suite now runs
every routed read over such a window against its raw twin. The snap test
pins the six-hour boundary itself. The MCP tools' raw fallback logs and
marks the span as the API's does.

* test(cli): restore the exit code to 0, not undefined, after the chDB streak test (#3271)

Assigning undefined back to process.exitCode is a no-op in Bun, so the 78
a chDB refusal sets leaked out whenever this file ran before any other set
the exit code: the CLI suite failed with every test passing.

* perf(infra): read the exact window, no start snap

Rounding a long window's start to the hour spared one day partition of raw
reads but left the summaries covering up to 59 minutes their charts,
facets and MCP tools did not. Measured on 7 days of a real org, the exact
start costs 1.75s for the hosts list (1.0s snapped, 19s before), so every
read now takes the window as sent. The long-window parity run keeps an
hour-aligned start, the splice's aligned case.

---------

Co-authored-by: Raisal P Wardana <IEatCodeDaily@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant